﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace 雷赛板卡上位机.View
{
    /// <summary>
    /// ProgreeBarView.xaml 的交互逻辑
    /// </summary>
    public partial class ProgreeBarView : Window
    {
        public double SleepTime;
        public ProgreeBarView()
        {
            InitializeComponent();
        }
        public ProgreeBarView(double sleepTime) : this()
        {
            this.SleepTime = sleepTime;
            this.Owner ??= App.Current.MainWindow;
            this.Title = "等待窗口";
            this.FontSize = 9;
            progressBar.Value = 0;
        }

        protected override async void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            StartOn();
        }
        private async void StartOn()
        {
            for (double i = 0.01; i < SleepTime; i += 0.01)
            {
                progressBar.Value = i / SleepTime * 100;
                await Task.Delay((int)(10));
            }
            await Task.Delay((int)(100));
            base.Close();
        }
    }
}
